/***************************************************************************
 *   Copyright (C) 2009-2010 by Lasse Liehu                                *
 *   lliehu@kolumbus.fi                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef WIN32LOGINWORKER_H
#define WIN32LOGINWORKER_H

#include <QThread>
class QString;

#include <WinInet.h>

#include "../loginoperation.h"

class GoogleLoginData;
class Win32LoginWorkerPrivate;

class Win32LoginWorker : public QThread
{
    Q_OBJECT
    public:
        explicit Win32LoginWorker(GoogleLoginData& loginData);
        ~Win32LoginWorker();
    signals:
        // from LoginOperation's API. These are forwarded to Win32LoginOperation
        void updateStatus(Login::Status);
        void setConclusion(Login::Conclusion, const QString& details);
    protected:
        virtual void run();
    private slots:
        void noticeStatusChange(Login::Status);
    private:
        void init();
        void sendReq();
        void queryResponseHeader();
        void receiveResponseData();
        void parseData();
        void closeHandles();
        Win32LoginWorkerPrivate *const d;
};

#endif // WIN32LOGINWORKER_H
